<template>
	<view v-if="orderInfo" class="content">
		<view class="wid100 bacFFF">
			<view class="wid90 mar dis disAl disJuC" style="height: 100rpx;">
				<view class="dis fowe600 foSi18">
					<view class="textCen">
						<view class="dis disAl disJuC borRad50 coFFF mar"
							:style="orderInfo.status >= 0?'background: #37BCC3;':'background: #A6A6A6;'"
							style="width: 35rpx;height: 35rpx;line-height: 38rpx;">1</view>
						<view class="mar-top10" style="color: #666565;">已下单</view>
					</view>
					<view style="width: 83rpx;height: 1rpx;background: #A6A6A6;margin-left: -6rpx;margin-top: 16rpx;">
					</view>
					<view class="textCen" style="margin-left: -6rpx;">
						<view class="dis disAl disJuC borRad50 coFFF mar"
							:style="orderInfo.status >= 2?'background: #37BCC3;':'background: #A6A6A6;'"
							style="width: 35rpx;height: 35rpx;line-height: 38rpx;">2</view>
						<view class="mar-top10" style="color: #666565;">待接单</view>
					</view>
					<view style="width: 83rpx;height: 1rpx;background: #A6A6A6;margin-left: -6rpx;margin-top: 16rpx;">
					</view>
					<view class="textCen" style="margin-left: -6rpx;">
						<view class="dis disAl disJuC borRad50 coFFF mar"
							:style="orderInfo.status >= 2?'background: #37BCC3;':'background: #A6A6A6;'"
							style="width: 35rpx;height: 35rpx;line-height: 38rpx;">3</view>
						<view class="mar-top10" style="color: #666565;">待收衣</view>
					</view>
					<view style="width: 83rpx;height: 1rpx;background: #A6A6A6;margin-left: -6rpx;margin-top: 16rpx;">
					</view>
					<view class="textCen" style="margin-left: -6rpx;">
						<view class="dis disAl disJuC borRad50 coFFF mar"
							:style="orderInfo.status >= 3 && (orderInfo.status != 9 && orderInfo.status != 10)?'background: #37BCC3;':'background: #A6A6A6;'"
							style="width: 35rpx;height: 35rpx;line-height: 38rpx;">3</view>
						<view class="mar-top10" style="color: #666565;">清洗中</view>
					</view>
					<view style="width: 83rpx;height: 1rpx;background: #A6A6A6;margin-left: -6rpx;margin-top: 16rpx;">
					</view>
					<view class="textCen" style="margin-left: -6rpx;">
						<view class="dis disAl disJuC borRad50 coFFF mar"
							:style="orderInfo.status >= 4 && (orderInfo.status != 9 && orderInfo.status != 10)?'background: #37BCC3;':'background: #A6A6A6;'"
							style="width: 35rpx;height: 35rpx;line-height: 38rpx;">4</view>
						<view class="mar-top10" style="color: #666565;">配送中</view>
					</view>
					<view style="width: 83rpx;height: 1rpx;background: #A6A6A6;margin-left: -6rpx;margin-top: 16rpx;">
					</view>
					<view class="textCen" style="margin-left: -6rpx;">
						<view class="dis disAl disJuC borRad50 coFFF mar"
							:style="orderInfo.status >= 7 && (orderInfo.status != 9 && orderInfo.status != 10)?'background: #37BCC3;':'background: #A6A6A6;'"
							style="width: 35rpx;height: 35rpx;line-height: 38rpx;">5</view>
						<view class="mar-top10" style="color: #666565;">已完成</view>
					</view>
				</view>
			</view>
		</view>
		<view class="wid90 mar bacFFF mar-top30 borRad20" style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);">
			<view class="wid90 mar dis disAl fowe800 foSi30" style="height: 74rpx;">配送信息</view>
			<view class="wid100 xia"></view>
			<view class="wid90 mar dis disAl" style="padding: 25rpx 0;">
				<image src="../../static/shohuo2.png" style="width: 30rpx;height: 46rpx;"></image>
				<view class="mar-left30 foSi25">
					<view class="dis disAl ">
						<view>{{orderInfo.address_take.name}}</view>
						<view class="mar-left30">{{orderInfo.address_take.phone}}</view>
					</view>
					<view class="mar-top20" style="color: #8B8B8B;">
						{{orderInfo.address_take.address+orderInfo.address_take.content}}</view>
				</view>
			</view>
			<view class="wid100 xia"></view>
			<view class="wid90 mar dis disAl" style="padding: 25rpx 0;">
				<image src="../../static/shohuo3.png" style="width: 30rpx;height: 46rpx;"></image>
				<view class="mar-left30 foSi25">
					<view class="dis disAl ">
						<view>{{orderInfo.address_give.name}}</view>
						<view class="mar-left30">{{orderInfo.address_give.phone}}</view>
					</view>
					<view class="mar-top20" style="color: #8B8B8B;">
						{{orderInfo.address_give.address+orderInfo.address_give.content}}</view>
				</view>
			</view>
		</view>
		<view v-if="orderInfo.status > 2 && orderInfo.collect_clerk_id != 0" class="wid90 mar bacFFF mar-top30 borRad20"
			style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);">
			<view class="wid90 mar dis disAl fowe800 foSi30" style="height: 74rpx;">收衣信息</view>
			<view class="wid100 xia"></view>
			<view class="wid90 mar" style="padding: 25rpx 0;">
				<!-- <view class="wid90 mar dis disAl disJuB" style="padding: 40rpx 0;">
					<view class="wid50 dis disAl fowe800 foSi30" style="height: 74rpx;">收衣照片</view>
					<view v-if="!collect_photo" class="dis disAl" @click="collectImage()">
						<view class="foSi25 mar-right10" style="color: #8B8B8B;;">上传照片</view>
						<image src="../../static/upImage.png" style="width: 35rpx;height: 32rpx;"></image>
					</view>
					<image v-if="collect_photo" :src="url+collect_photo" style="width: 80rpx;height: 80rpx;" @click="collectImage()"></image>
				</view> -->
				<view class="fowe600 foSi25 mar-right20">
					<view class="mar-bott20">配送员姓名：{{orderInfo.collect_clerk_user.name}}</view>
					<view @click="callPhone(orderInfo.collect_clerk_user.mobile)">配送员手机号：
						{{orderInfo.collect_clerk_user.mobile}}</view>
				</view>
				<view v-if="collect_photo.length > 0" class="wid100 " style="padding: 30rpx 0;">
					<view class="fowe600 foSi25 mar-right20 mar-bott20">收衣照片：</view>
					<image v-for="(item,index) in collect_photo" :src="url+item" style="width: 120rpx;height: 120rpx;"
						:style="(index + 1) % 4 == 0?' margin-right:0rpx;':' margin-right:40rpx;'"
						@click="clickImg(index,0)"></image>
				</view>
			</view>
		</view>
		<view v-if="orderInfo.status >= 4 && orderInfo.send_clerk_id != 0" class="wid90 mar bacFFF mar-top30 borRad20"
			style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);">
			<view class="wid90 mar dis disAl fowe800 foSi30" style="height: 74rpx;">配送详细信息</view>
			<view class="wid100 xia"></view>
			<view class="wid90 mar" style="padding: 25rpx 0;">
				<!-- <view class="wid90 mar dis disAl disJuB" style="padding: 40rpx 0;">
					<view class="wid50 dis disAl fowe800 foSi30" style="height: 74rpx;">配送照片</view>
					<view v-if="!send_photo" class="dis disAl" @click="sendImage()">
						<view class="foSi25 mar-right10" style="color: #8B8B8B;;">上传照片</view>
						<image src="../../static/upImage.png" style="width: 35rpx;height: 32rpx;"></image>
					</view>
					<image v-if="send_photo" :src="url+send_photo" style="width: 80rpx;height: 80rpx;" @click="sendImage()"></image>
				</view> -->
				<view class="fowe600 foSi25 mar-right20">
					<view class="mar-bott20">配送员姓名：{{orderInfo.send_clerk_user.name}}</view>
					<view @click="callPhone(orderInfo.send_clerk_user.mobile)">配送员手机号：
						{{orderInfo.send_clerk_user.mobile}}</view>
				</view>
				<view v-if="send_photo.length > 0" class="wid100 " style="padding: 30rpx 0;">
					<view class="fowe600 foSi25 mar-right20 mar-bott20">配送照片：</view>
					<image v-for="(item,index) in send_photo" :src="url+item" style="width: 120rpx;height: 120rpx;"
						:style="(index + 1) % 4 == 0?' margin-right:0rpx;':' margin-right:40rpx;'"
						@click="clickImg(index,0)"></image>
				</view>
			</view>
		</view>
		<view class="wid90 mar bacFFF mar-top30 borRad20" style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);">
			<view class="wid90 mar dis disAl" style="height: 96rpx;">
				<image src="../../static/shangjia_icon.png" style="width: 39rpx;height: 35rpx;"></image>
				<view class="fowe800 foSi35 mar-left20">{{orderInfo.gasstation.name}}</view>
			</view>
			<view class="wid100 xia"></view>
			<block v-for="(item, index) in JSON.parse(orderInfo.goods_info)" :key="index">
				<view class="wid90 mar dis disAl " style="padding: 25rpx 0;">
					<view class="wid25" style="height: 115rpx;">
						<image :src="url+item.goods_pic" class="hei100" style="width: 115rpx;"></image>
					</view>
					<view style="width: 75%;">
						<view class="foSi25 fowe600 yclh">{{item.goods_name}}</view>
						<view class="mar-top30 dis disAl disJuB foSi25">
							<view style="color: #A8AAAA;">×{{item.nums}}</view>
							<view class="fowe600" style="color: #37BCC3;">¥{{item.money}}</view>
						</view>
					</view>
				</view>
				<view class="wid100 xia"></view>
			</block>
			<view class="wid90 mar " style="padding: 30rpx 0;">
				<view class="fowe600 foSi25 mar-right20 mar-bott20">衣物照片：</view>
				<image v-for="(item,index) in orderInfo.photo" :src="url+item" style="width: 120rpx;height: 120rpx;"
					:style="(index + 1) % 4 == 0?' margin-right:0rpx;':' margin-right:40rpx;'" @click="clickImg(index)">
				</image>
			</view>
			<view class="wid100 xia"></view>
			<view class="wid90 mar mar-top30 foSi25 fowe600">
				<view v-if="orderInfo.collect_clerk_id != 0" @click="callPhone(orderInfo.collect_clerk_user.mobile)">
					接单人： {{orderInfo.collect_clerk_user.name}} / {{orderInfo.collect_clerk_user.mobile}}</view>
				<view class="mar-top20">订单金额： ¥{{orderInfo.total_amount}}</view>
				<view class="mar-top20">优惠券抵扣： ¥{{orderInfo.coupon_money}}</view>
				<view class="mar-top20">实际支付： <span style="color: #37BCC3;">¥{{orderInfo.pay_amount}}</span></view>
				<view class="dis disAl mar-top20">
					<view class="mar-right20">订单编号： {{orderInfo.ordernum}}</view>
					<image src="../../static/fuzhi1.png" @click="fuzhi(orderInfo.ordernum)"
						style="width: 24rpx;height: 26rpx;"></image>
				</view>
				<view class="mar-top20">提交时间：{{orderInfo.createtime}}</view>
				<view class="mar-top20">预约时间：{{dateFormat(orderInfo.reservation_time,1)}}~{{dateFormat(orderInfo.reservation_timeend,2)}}</view>
				<view class="mar-top20">支付方式：微信支付</view>
				<view class="mar-top20">备注：{{orderInfo.remarks?orderInfo.remarks:'无'}}</view>
				<view style="height: 30rpx;"></view>
			</view>
		</view>
		<view style="height: 50rpx;"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				id: 0,
				orderInfo: '',
				collect_photo: [],
				send_photo: []
			}
		},
		onLoad(option) {
			this.id = option.id
			this.getList()
		},
		onShow() {},
		methods: {
			dateFormat(time,type) {
				var date = new Date(time*1000);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				if(type == 1){
					return year + "年" + month + "月" + day + "日" + hours + ":" + minutes;
				}else{
					return hours + ":" + minutes;
				}
				// return year + "-" + month + "-" + day;
			},
			callPhone(tel) {
				uni.makePhoneCall({
					phoneNumber: tel + ""
				})
			},
			clickImg(index) {
				var that = this;
				// console.log(that.orderInfo.photo , "能打印出图片合集吗");
				let url = that.orderInfo.photo.map(item => {
					// console.log(item , "能打印出图片链接吗");
					return that.url + item;
				})
				uni.previewImage({
					current: index, //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
					urls: url, // 当前显示图片的http链接，默认是第一个
				})
			},
			fuzhi(value) {
				//提示模板
				uni.showModal({
					content: value, //模板中提示的内容
					confirmText: '复制内容',
					success: () => { //点击复制内容的后调函数
						//uni.setClipboardData方法就是讲内容复制到粘贴板
						uni.setClipboardData({
							data: value, //要被复制的内容
							success: () => { //复制成功的回调函数
								uni.showToast({ //提示
									title: '复制成功'
								})
							}
						});
					},
				});
			},
			getList() {
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_pay_order_info',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						id: that.id,
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							if (result.data.collect_photo != null) {
								that.collect_photo = result.data.collect_photo.split(",");
							}
							if (result.data.send_photo != null) {
								that.send_photo = result.data.send_photo.split(",");
							}
							that.orderInfo = result.data
							that.orderInfo.photo = that.orderInfo.photo.split(",");
						}
					}
				})
			},
		}
	}
</script>

<style>
	.content {
		background: #F3F1F1;
		min-height: 100vh;
	}

	.xia {
		height: 1rpx;
		border-bottom: 1rpx dashed #E1DFDF;
	}
</style>